Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delete user fuctionality, increase verbosity and general refactoring #2

Merged
merged 23 commits into from
Oct 7, 2024

Conversation

mira-miracoli
Copy link
Contributor

@mira-miracoli mira-miracoli commented Feb 22, 2024

Important info:
delete a user means:
The user will notified using the notification framwork and an "urgent" notification, which should be delivered by email and can not be unsubscribed. The user will be marked as deleted in the database, all running jobs will be cancelled, all sessions will be terminated and login is blocked.
However it will NOT delete all their data, histories etc. on the spot.
This only happens when a user is purged

Delete user functionality works as follows:
The user can specify the flag --delete-user <MIN_SEVERITY> , where <MIN_SEVERITY> must be one of the defined VALID_SEVERITIES (low, medium and high), this is not case sensitive.

Everytime the script matches a file in a jwd to the malware database,
and if the severity level of that malware is EQUAL OR HIGHER than the specified <MIN_SEVERITY>, the Galaxy user ID is added to a set named delete_users.

Once the iteration over the running jobs found in the databse is done, the script iterates over the delete_users set, requests an encoded version of their user ID from Galaxy's API (GALAXY_BASE_URL and GALAXY_API_KEY must be set in the ~/.bashrc file of the user running WALL·E) and then creates a notification that will stay in the database for 6 months and sends a DELETE request to /api/users/<encoded_id>.

The second, more minor change in this PR is the amount of information that is logged in verbosity mode:

- TIMESTAMP GALAXY_USER JOB_ID MALWARE_CLASS MALWARE MALWARE_VERSION PATH
+ TIMESTAMP MALWARE_SEVERITY USER_ID USER_NAME USER_MAIL TOOL_ID GALAXY_JOB_ID RUNNER_JOB_ID RUNNER_NAME MALWARE_CLASS OBJECT_STORE_ID MALWARE_VERSION PATH

tasks/main.yml Outdated Show resolved Hide resolved
tasks/main.yml Outdated Show resolved Hide resolved
templates/walle.py Outdated Show resolved Hide resolved
templates/walle.py Outdated Show resolved Hide resolved
templates/walle.py Outdated Show resolved Hide resolved
mira-miracoli and others added 4 commits February 28, 2024 09:40
Co-authored-by: Björn Grüning <[email protected]>
Co-authored-by: Björn Grüning <[email protected]>
Co-authored-by: Björn Grüning <[email protected]>
@mira-miracoli
Copy link
Contributor Author

Should we also log when we delete users, or does it disturb the logs too much (e.g. when you want to use telegraf)

@mira-miracoli
Copy link
Contributor Author

mira-miracoli commented Mar 4, 2024

shall I split it up in multiple PRs so we can merge the fix for symlinks and increased verbosity now?

@mira-miracoli
Copy link
Contributor Author

I think this is finally ready for review :)

@mira-miracoli mira-miracoli changed the title Add delete user fuctionality, increase verbosity and refactor env var process Add delete user fuctionality, increase verbosity and general refactoring Sep 18, 2024
Copy link
Member

@sanjaysrikakulam sanjaysrikakulam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It reads fine at first glance. Has this been tested? Would it be possible to add some mock tests?

@mira-miracoli
Copy link
Contributor Author

Yes, I tested on my instance and I can give you access, so you can try yourself if you want.
Test coverage would be nice, yes, I can start working on this today

@sanjaysrikakulam
Copy link
Member

Oh, cool then. Yup, test coverage would be excellent! Thank you!

@mira-miracoli
Copy link
Contributor Author

But it might be inefficient, because I never wrote cli tests for python before and the last unit test is 5 y ago. also if we merge #7 we might need to rewrite/change it again.

@sanjaysrikakulam
Copy link
Member

Feel free to merge or wait for @bgruening's review.

@bgruening
Copy link
Member

Go for it! Fingers crossed!

@mira-miracoli
Copy link
Contributor Author

Merging will not change our production servers – versions are fixed

@mira-miracoli mira-miracoli merged commit 111c510 into usegalaxy-eu:main Oct 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants